<template>
  <div class="img-contain">
    <div class="overlay">
      <p class="overlay-text">I don't like this one</p>
      <button @click="isShowing = !isShowing">Replace!</button>
    </div>
    <transition name="flip" mode="out-in">
      <div class="img-t" v-if="!isShowing">
        <slot></slot>
      </div>
      <img v-else src='~/assets/plane_3.jpg' alt=''>
    </transition>
  </div>
</template>

<script>
import {ref} from 'vue'

export default {
  name: 'TransitChild',
  setup() {
    let isShowing = ref(false)

    return {isShowing}
  },
}
</script>

<style scoped>

button {
  font-family: "Bitter";
  background: #c62735;
  color: white;
  border: 0;
  padding: 5px 15px;
  margin: 0 10px;
  border-radius: 4px;
  outline: 0;
  cursor: pointer;
}

.img-contain {
  width: 410px;
  height: 310px;
  overflow: hidden;
  transform-origin: 50% 50%;
}

img, .img-t {
  width: 400px;
  height: 300px;
  /* width: 100%; */
  transform-origin: 50% 50%;
  cursor: pointer;
  transform: scaleY(1) translateZ(0);
  margin: 5px;
  overflow: hidden;
}

.img-contain:hover .overlay {
  opacity: 1;
  background: rgba(0, 0, 0, 0.6);
  transition: 0.3s all ease-out;
}

.img-contain .overlay {
  position: absolute;
  z-index: 1000;
  display: block;
  width: 405px;
  height: 305px;
  margin: 5px;
  opacity: 0;
  overflow: hidden;
  transition: 0.3s all ease-in;
}

.overlay-text {
  margin-top: 100px;
}

.flip-enter-active {
  transition: all 0.2s cubic-bezier(0.55, 0.085, 0.68, 0.53);
  transform-origin: 50% 50%;
}

.flip-leave-active {
  transform-origin: 50% 50%;
  transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.flip-enter-from,
.flip-leave-to {
  transform-origin: 50% 50%;
  transform: scaleY(0) translateZ(0);
  opacity: 0;
}

</style>